/*
 *  ConcreteLine.cpp
 *  SoundController0002
 *
 *  Created by jiro on 11/10/04.
 *  Copyright 2011 jiro music. All rights reserved.
 *
 */

#include "ConcreteLine.h"
#include "ConcreteNote.h"

namespace sc
{
namespace system0039
{

	ConcreteLine::ConcreteLine()
	{}

	double ConcreteLine::GetDuration() const
	{
		double duration = 0;
		for ( int i = 0, count = size(); i < count; i++ )
		{
			duration += at( i ).GetDuration();
		}
		return duration;
	}

	void ConcreteLine::ToSoundElements( 
		std::vector< std::vector< const ::sc::SoundElement32* > >& line0,
		std::vector< std::vector< const ::sc::SoundElement32* > >& line1 ) const
	{
		for ( int i = 0, count = size(); i < count; i++ )
		{
			const ConcreteNote& note = at( i );
			std::vector< const ::sc::SoundElement32* > notes[ 2 ];
			note.ToSoundElements( notes[ 0 ], notes[ 1 ] );
			line0.push_back( notes[ 0 ] );
			line1.push_back( notes[ 1 ] );
		}
	}

	std::string ConcreteLine::ToString( int tabCount ) const
	{
		std::stringstream ss;
		for ( int i = 0; i < tabCount; i++ )
		{
			ss << "\t";
		}
		ss << "ConcreteLine\n";
		for ( int i = 0, count = size(); i < count; i++ )
		{
			ss << at( i ).ToString( 1 ) << "\n";
		}
		ss << "\n";
		return ss.str();
	}

}
}
